function [V,T] = read_easymesh(filename,show)
% function [V,T] = read_easymesh(filename,show)
% this function is used to show the mesh of easymesh
% first read the node file

if nargin == 1

    show = 0;

end

node_file = strcat(filename,'.n');

fid = fopen(node_file, 'r');

c = textscan(fid,'%d',1);

node_count = c{1};

c = textscan(fid,'%s %f %f %d',node_count);

V = zeros(node_count,2);

V(:,1) = c{2};

V(:,2) = c{3};

fclose(fid);



% then read the element file

ele_file = strcat(filename,'.e');

fid = fopen(ele_file, 'r');

c = textscan(fid,'%d',1);

ele_count = c{1};

T = zeros(ele_count,3);

c = textscan(fid,'%s %d %d %d %d %d %d %d %d %d %f %f %d',ele_count);

T(:,1) = c{2}+1;

T(:,2) = c{3}+1;

T(:,3) = c{4}+1;

fclose(fid);

if show

    plot_t(V,T); 

    axis([min(V(:,1)) max(V(:,1)) min(V(:,2)) max(V(:,2))]);

end